(function($) {

   
	var DEFAULT_TOP_POS = 180;
	var DEFAULT_LEFT_POS = 70;	
	var H_GAP = 20;
	var V_GAP = 80;
	
	
	$.fn.arrangeImage = function(images,numOfImgPerRow) {
		
		var imagePositions = [];
					
		for(var index = 0; index < images.length; index++){
			
			var topPos = 0;
			var leftPos = 0;
			
			if(index == 0)
			{
				imagePositions[index] = $.fn.createImgPos(images[index], DEFAULT_LEFT_POS,DEFAULT_TOP_POS);
				continue;
				
			}
			
			var prevTopPos = imagePositions[index - 1].top;
			var prevLeftPos = imagePositions[index - 1].left  + $(images[index]).width() + H_GAP;
			
			if(index % numOfImgPerRow == 0)
			{
				prevTopPos +=  V_GAP; 
				prevLeftPos = DEFAULT_LEFT_POS;
				
			}
													
			imagePositions[index] = $.fn.createImgPos(images[index], prevLeftPos,prevTopPos);
			
			
		};
		
		return imagePositions;

	};
	
	$.fn.createImgPos = function(image, leftPos, topPos){
		return {img: image, top: topPos, left: leftPos};
	};
	

})(jQuery);